# JFLAGS=-g
PARSER_DIR = ../parser/
GENERATED_DIR = ../generated/
BUILD_DIR = ../build
ABSYN_DIR = ../absyn
RTL_DIR = ../rtl
MIPS_DIR = ../mips
JFLAGS= -sourcepath ${PARSER_DIR}:${GENERATED_DIR}:${ABSYN_DIR}:${RTL_DIR}:${MIPS_DIR} -d ${BUILD_DIR}

#TEST_HOME = /home/tongxiaoyu/workspace
TEST_HOME = /home/rodrigo/Documents/I-2010/cdProj/dev

MIPS-TEST_DIR = ${TEST_HOME}/ts-100118/quiet/mips
RTL-TEST_DIR = ${TEST_HOME}/ts-100118/quiet/rtl
SEMANTIC-TEST_DIR = ${TEST_HOME}/ts-100118/quiet/semantic
PARSER-TEST_DIR = ${TEST_HOME}/ts-100118/quiet/parser
LEXER-TEST_DIR = ${TEST_HOME}/ts-100118/quiet/lexer
NOISY_SIMPLE_DIR = ${TEST_HOME}/ts-100118/noisy/simple
NOISY_MEDIUM_DIR = ${TEST_HOME}/ts-100118/noisy/medium
NOISY_ADVANCED_DIR = ${TEST_HOME}/ts-100118/noisy/advanced

# SEMANTIC-INCORRECT_DIR =/Home/tongxiaoyu/workspace/ts-100118/incorrect/semantic
SEMANTIC-INCORRECT_DIR =${TEST_HOME}ts-100118/incorrect/semantic

all: 
	cd ${GENERATED_DIR}; javacc ${PARSER_DIR}/parser.jj;
	javac ${JFLAGS} ../generated/UcParser.java

make-and-test:
	cd ${GENERATED_DIR}; javacc ${PARSER_DIR}/parser.jj;
	javac ${JFLAGS} ../generated/UcParser.java
	java -ea -cp ${BUILD_DIR} UcParser ${TESTFILE}

clean:
	cd ${GENERATED_DIR}; rm *.java
	cd ${BUILD_DIR}; rm *.class

test: 
	java -ea -cp ${BUILD_DIR} UcParser ${TESTFILE}

test-semantic:
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s01.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s02.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s03.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s04.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s05.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-TEST_DIR}/s06.c

test-parser:
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p01.c
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p02.c
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p03.c
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p04.c
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p05.c

test-lexer:
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l01.c
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l02.c
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l03.c
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l04.c
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l05.c
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l06.c

test-simple:
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim01.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim02.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim03.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim04.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim05.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim06.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim07.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim08.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim09.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim10.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_SIMPLE_DIR}/sim11.c

test-medium:
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_MEDIUM_DIR}/circle.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_MEDIUM_DIR}/fac.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_MEDIUM_DIR}/fac-b.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_MEDIUM_DIR}/fib.c

test-advanced:
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/8queens.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/bubble.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/eval.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/primes.c
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/quick.c

test-incorrect-semantic:
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se01.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se02.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se03.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se04.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se05.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se06.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se07.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se08.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se09.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se10.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se11.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se12.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se13.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se14.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se15.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se16.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se17.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se18.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se19.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se20.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se21.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se22.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se23.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se24.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se25.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se26.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se27.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se28.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se29.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se30.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se31.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se32.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se33.c
	java -ea -cp ${BUILD_DIR} UcParser ${SEMANTIC-INCORRECT_DIR}/se34.c

test-correct-rtl:
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r01.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r02.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r03.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r04.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r05.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r06.c
	java -ea -cp ${BUILD_DIR} UcParser ${RTL-TEST_DIR}/r10.c

test-others-rtl:
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l05.c
	java -ea -cp ${BUILD_DIR} UcParser ${PARSER-TEST_DIR}/p04.c

test-correct-mips:
	java -ea -cp ${BUILD_DIR} UcParser ${MIPS-TEST_DIR}/m01.c
	java -ea -cp ${BUILD_DIR} UcParser ${MIPS-TEST_DIR}/m02.c
	java -ea -cp ${BUILD_DIR} UcParser ${MIPS-TEST_DIR}/m03.c

test-required-mips:
	java -ea -cp ${BUILD_DIR} UcParser ${LEXER-TEST_DIR}/l05.c

test-quick:
	java -ea -cp ${BUILD_DIR} UcParser ${NOISY_ADVANCED_DIR}/quick.c